package teaching.io.base;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * 字符输入流示例。
 * 
 * @author deng.zhao
 * @version 1.0 2018/03/28
 *
 */
public class ReaderExample {

	public static void main(String[] args) {
		
		int length;
		char[] buf = new char[512];

		try (Reader reader = new FileReader("d:/test.txt");) {			
			while ((length = reader.read(buf)) != -1) {
				System.out.print(new String(buf, 0, length));
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		System.out.println("DONE!");
	}

}
